home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
MATH
/
MFLOAT10.ZIP
/
MFLOAT.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-28
|
11KB
|
258 lines
#ifndef mfloat_h
#define mfloat_h
#include <string.h> /* strlen() */
/* ------------------------------------------------------------------------ */
/* mfloat types */
/* ------------------------------------------------------------------------ */
#ifndef mfloatwords
#define mfloatwords 16 /* maximum precision */
#endif
typedef int mfloata[mfloatwords];/* mfloat array */
#define mfloat_ int far * /* pointer to array */
#define mfloat mfloata /* for use in 'C' programs */
/* ------------------------------------------------------------------------ */
/* compiler control */
/* ------------------------------------------------------------------------ */
#ifdef __cplusplus
extern "C" { /* do not extend names (C++) */
#endif
#ifdef __STDC__ /* ANSI comatibility mode */
#ifndef __HUGE__
#error ANSI compatibility only with model 'huge'
#endif
#define far
#undef mfloat_
#define mfloat_ int *
#pragma option -Ff /* automatic far data */
#define pascal
#pragma option -p /* pascal calling convention */
#pragma option -l-c- /* no case sensitive link */
#pragma option -u- /* do not generate underlines */
#define _fstrlen(v) strlen(v)
#endif
/* ------------------------------------------------------------------------ */
/* mfloat basic functions */
/* ------------------------------------------------------------------------ */
void far pascal setmantissawords(int number);
extern int far pascal getmantissawords(void);
extern void far pascal reseterror(void);
extern char far pascal geterror(void);
extern mfloat_ far pascal equm(mfloat_ a, /* a <- b */
const mfloat_ b);
extern mfloat_ far pascal addm(mfloat_ a, /* a <- a + b */
const mfloat_ b);
extern mfloat_ far pascal subm(mfloat_ a, /* a <- a - b */
const mfloat_ b);
extern mfloat_ far pascal multm(mfloat_ a, /* a <- a * b */
const mfloat_ b);
extern mfloat_ far pascal divm(mfloat_ a, /* a <- a / b */
const mfloat_ b);
extern mfloat_ far pascal multi(mfloat_ a, /* a <- a * b */
int b);
extern mfloat_ far pascal divi(mfloat_ a, /* a <- a / b */
int b);
extern mfloat_ far pascal inversm(mfloat_ a); /* a <- 1/a */
extern mfloat_ far pascal negm(mfloat_ a); /* a <- - a */
extern char far pascal eqzero(const mfloat_ a); /* eqZero <- a = 0 */
extern char far pascal gtzero(const mfloat_ a); /* gtZero <- a > 0 */
extern char far pascal gezero(const mfloat_ a); /* geZero <- a >= 0 */
extern char far pascal gtm(const mfloat_ a, /* gtm <- a > b */
const mfloat_ b);
extern char far pascal eqm(const mfloat_ a, /* eqm <- a = b */
const mfloat_ b);
extern mfloat_ far pascal getzerom(mfloat_ a); /* a <- 0 */
extern mfloat_ far pascal getonem(mfloat_ a); /* a <- 1 */
extern mfloat_ far pascal getpim(mfloat_ a); /* a <- pi */
extern mfloat_ far pascal getln2m(mfloat_ a); /* a <- ln(2) */
extern mfloat_ far pascal getln10m(mfloat_ a); /* a <- ln(10) */
int far pascal strtomf(mfloat_ a, /* a <- b */
const char far * b);
char far * far pascal mftoa(char far * str, /* str <- a */
const mfloat_ a,
int len);
char far * far pascal mftostr(char far * str, /* str <- a */
const mfloat_ a,
int len,
const char far * format);
double far pascal mftod(const mfloat_ b); /* mftod <- b */
long double far pascal mftold(const mfloat_ b); /* mftold <- b */
extern mfloat_ far pascal dtomf(mfloat_ a, /* a <- b */
double b);
extern mfloat_ far pascal ldtomf(mfloat_ a, /* a <- b */
long double b);
/* ------------------------------------------------------------------------ */
/* standard functions (Borland C: MATH.H) */
/* ------------------------------------------------------------------------ */
extern mfloat_ far pascal acosm(mfloat_ a); /* a <- acos(a) */
extern mfloat_ far pascal asinm(mfloat_ a); /* a <- asin(a) */
extern mfloat_ far pascal atanm(mfloat_ a); /* a <- atan(a) */
extern mfloat_ far pascal atan2m(mfloat_ a, /* a <- atan2(a,b) */
const mfloat_ b);
/* atof see strtomf */
extern mfloat_ far pascal ceilm(mfloat_ a); /* a <- ceil(a) */
extern mfloat_ far pascal cosm(mfloat_ a); /* a <- cos(a) */
extern mfloat_ far pascal coshm(mfloat_ a); /* a <- cosh(a) */
extern mfloat_ far pascal expm(mfloat_ a); /* a <- exp(a) */
extern mfloat_ far pascal fabsm(mfloat_ a); /* a <- fabs(a) */
extern mfloat_ far pascal floorm(mfloat_ a); /* a <- floor(a) */
extern mfloat_ far pascal fmodm(mfloat_ a, /* a <- fmod(a,b) */
const mfloat_ b);
extern mfloat_ far pascal frexpm(mfloat_ a, /* a <- frexp(a,b) */
int * b);
extern mfloat_ far pascal hypotm(mfloat_ a, /* a <- hypot(a,b) */
const mfloat_ b);
extern mfloat_ far pascal ldexpm(mfloat_ a, /* a <- ldexp(a,b) */
int b);
extern mfloat_ far pascal logm(mfloat_ a); /* a <- log(a) */
extern mfloat_ far pascal log10m(mfloat_ a); /* a <- log10(a) */
extern mfloat_ far pascal modfm(mfloat_ a, /* a <- modf(a,b) */
mfloat_ b);
extern mfloat_ far pascal powm(mfloat_ a, /* a <- pow(a,b) */
const mfloat_ b);
extern mfloat_ far pascal pow10m(mfloat_ a, /* a <- 10**b */
int b);
extern mfloat_ far pascal sinm(mfloat_ a); /* a <- sin(a) */
extern mfloat_ far pascal sinhm(mfloat_ a); /* a <- sinh(a) */
extern mfloat_ far pascal sqrtm(mfloat_ a); /* a <- sqrt(a) */
extern mfloat_ far pascal tanm(mfloat_ a); /* a <- tan(a) */
extern mfloat_ far pascal tanhm(mfloat_ a); /* a <- tanh(a) */
/* ------------------------------------------------------------------------ */
/* extended standard functions */
/* ------------------------------------------------------------------------ */
extern mfloat_ far pascal acoshm(mfloat_ a); /* a <- acosh(a) */
extern mfloat_ far pascal acotm(mfloat_ a); /* a <- acot(a) */
extern mfloat_ far pascal acothm(mfloat_ a); /* a <- acoth(a) */
extern mfloat_ far pascal asinhm(mfloat_ a); /* a <- asinh(a) */
extern mfloat_ far pascal atanhm(mfloat_ a); /* a <- atanh(a) */
extern mfloat_ far pascal cossinm(mfloat_ a, /* a <- cos(a), */
mfloat_ b); /* b <- sin(a) */
extern mfloat_ far pascal cotm(mfloat_ a); /* a <- cot(a) */
extern mfloat_ far pascal cothm(mfloat_ a); /* a <- coth(a) */
extern mfloat_ far pascal exp10m(mfloat_ a); /* a <- 10 ** a */
extern mfloat_ far pascal sqrm(mfloat_ a); /* a <- sqr(a) */
extern mfloat_ far pascal truncm(mfloat_ a); /* a <- trunc(a) */
/* ------------------------------------------------------------------------ */
/* internal functions */
/* ------------------------------------------------------------------------ */
extern void far pascal setmantissawords_(int number);
extern char far * far pascal mftostr_(char far * a, /* a <- b */
const mfloat_ b,
int far * len,
const char far * format);
extern int far pascal strtomf_(mfloat_ a, /* a <- b */
const char far * b,
const int len);
extern void far pascal mftod_(double far * a, /* a <- b */
const mfloat_ b);
extern void far pascal mftold_(long double far * a, /* a <- b */
const mfloat_ b);
/* ------------------------------------------------------------------------ */
/* constants */
/* ------------------------------------------------------------------------ */
extern far const pascal mfloata zerom;
extern far const pascal mfloata onem;
extern far const pascal mfloata pim;
extern far const pascal mfloata ln2m;
extern far const pascal mfloata ln10m;
extern far const pascal mfloata powten;
/* ------------------------------------------------------------------------ */
/* static variables */
/* ------------------------------------------------------------------------ */
#ifdef mfloatb
extern far int pascal mantissawords; /* for internal use only */
extern far char pascal calculationerror;
#else
extern far int pascal mantissawords = mfloatwords-1; /* normal use */
extern far char pascal calculationerror = 0;
/* ------------------------------------------------------------------------ */
/* included functions */
/* ------------------------------------------------------------------------ */
void far pascal setmantissawords(int number) {
if (number > mfloatwords - 1)
number = mfloatwords - 1;
setmantissawords_(number);
};
int far pascal strtomf(mfloat_ a, const char far * b) {
return(strtomf_(a,b,_fstrlen(b)));
}
char far * far pascal mftoa(char far * str, const mfloat_ a, int len) {
mftostr_(str,a,&len,".32767F");
str[len] = 0;
return str;
}
char far * far pascal mftostr(char far * str, const mfloat_ a, int len,
const char far * format) {
mftostr_(str,a,&len,format);
str[len] = 0;
return str;
};
double far pascal mftod(const mfloat_ b) {
double tmp;
mftod_(&tmp, b);
return tmp;
}
long double far pascal mftold(const mfloat_ b) {
long double tmp;
mftold_(&tmp, b);
return tmp;
}
#endif /* ifdef mfloatb else */
/* ------------------------------------------------------------------------ */
/* compiler control */
/* ------------------------------------------------------------------------ */
#ifdef __cplusplus
} /* do not extend function names (C++) */
#endif
#ifdef __STDC__
#undef far /* delete some of the self made defines */
#undef pascal
#undef huge
#pragma option -u /* generate underlines */
#pragma option -p- /* no pascal calling convention */
#endif
#endif /* ifndef mfloat_h */
/* ------------------------------------------------------------------------ */
/* End of MFLOAT.H */
/* ------------------------------------------------------------------------ */